 
 
$(function(){
	
  var endId=[];  
  var insertid;
  var deleteid;
  var object={};
  var totalPage=0; 
  var page=1;
  var information={};
  requestRefer();//已提交数据

  //跳转到详情界面
  $("#export-tablebody").parent().on("click", ".detail", function() {
		var id= $(this).attr("data-id");
		window.location.href='DetailInfo.jsp?detailId='+id;
		/* location.search = "?detailId="+id;*/
  })
  
  //分页，首页
  $("#export-headPage").click(function(){
  	page=1;
  	$("#export-totalPage").html(page+"/"+totalPage);
  	requestPage(page);
  })
  //分页，尾页
  $("#export-endPage").click(function(){
  	$("#export-totalPage").html(totalPage+"/"+totalPage);
  	page=totalPage;
  	requestPage(page);
  })
  //分页，上一页
  $("#export-prevPage").click(function(){
  	if(page<=1)
  	{
  		page=1;
  	}
  	else
  	{
  		page=page-1;
  		$("#export-totalPage").html(page+"/"+totalPage);
  		requestPage(page);
  	}

 })
  //分页，下一页
   $("#export-nextPage").click(function(){  
  	if(page>=totalPage)
  	{
  		page=page-1;  		
  	}
  	else
  	{
  		page=page+1;
  		$("#export-totalPage").html(page+"/"+totalPage);
  		requestPage(page);
  	}
  	return false;
  	
  });
 
 
  
  ////
//分页
  function requestPage(page)
  {	
  	$("#export-tablebody").html("");
  	 if(information!=null){
  		 information.currentPage=page;
  		 var url="FirstCheckFilter/firstCheckGetList.do";//地址----------------------------------
  		  YuXi.util.get(url,information,function(data){
  			  	//console.log(data);
  			  	page=data.currentPage;
  				totalPage=data.totalPage;
  				object=data.list;
  			  	$("#export-tablebody").html("");		
  			  	setData(object);
  				
  			},function(){
  				//console.log("查询失败");
  			});
  	 }
  	 else{
  		 var dapage={currentPage:page};
  			var url="FirstCheckFilter/firstCheckGetList.do";
  			/*------*/								
  			YuXi.util.get(url,dapage,function(data){
  				//console.log(data);
  				page=data.currentPage;
  				totalPage=data.totalPage;
  				object=data.list;
  				setData(object);
  			 },function(){
  				 //console.log("分页出错");
  			 })
  	 }
  }
    
  
  
  //设置数据
  function setData(object){
  	$("#export-tablebody").append("");
  	for(var i=0;i<object.length;i++)
  	{
  		var time=YuXi.getTime.get(object[i].createTime);			
  		if( object[i].informationProfile.length>15)
  			object[i].informationProfile= object[i].informationProfile.substring(0,15)+"...";
  		var html="<tr ><td><input value="+object[i].id+" type='checkbox' name='together' data-id="+object[i].id+" > "+object[i].informationAccount+
  		"</td><td >"+object[i].informationProfile+"</td>"+
  		"</td><td >" + object[i].informationSortNames + "</td>" +
  		"</td><td >" + object[i].informationClassificationNames + "</td>" +
  		"</td><td >" + object[i].informationSourceNames + "</td>" +
  		"<td >"+object[i].inputPerSonNames+"</td><td >"+time+"</td>"+
  		"<td><a data-id="+object[i].id+" href='javascript:void(0)'; class='detail'>详情</a> &nbsp;&nbsp;<a data-flowId=" + object[i].flowId + " data-id="+object[i].id+" href='javascript:void(0);' class='update'>修改</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='delete'>结束</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0);' class='insert'>提交</a>&nbsp;&nbsp;<a data-id="+object[i].id+" href='javascript:void(0)'; class='reset'>打回</a> </td></tr>";
  		$("#export-tablebody").append(html);
  	}
  }

  //向后台请求已提交的信息数据
  function requestRefer()
  {	
  	

  var url="FirstCheckFilter/firstCheckGetList.do";
    YuXi.util.get(url,"null",function(data){
  		object=data.list;
  		page=data.currentPage;
  		totalPage=data.totalPage;	
  		$("#export-totalPage").html(page+"/"+totalPage);
  		//console.log(data);
  		setData(object);
  	},function(){});
  }

  //简介，分级，渠道，状态，时间（今天,一周...）查找
  function firstSearch()
  {
  	var information={};
  	if($("#export-profile").val()!=null&&$("#profile").val()!="")
  		information.key=$("#export-profile").val();//简介
  	var curFlowText=$(".export-state option:selected").val();
  	curFlowText==null?"":information.curFLow=curFlowText;//当前状态
  	if($(".export-reSearchSourceSel option:selected").val()!="null"&&$(".export-reSearchSourceSel option:selected").val()!="")
  		information.informationSource=$(".export-reSearchSourceSel option:selected").val()//来源渠道
  	if($(".export-pes option:selected").val()!="null"&&$(".export-pes option:selected").val()!="")
  		information.informationLv=$(".export-pes option:selected").val();//分级
  	if($(".export-reSearchsort option:selected").val()!="null"&&$(".export-reSearchsort option:selected").val()!="")
  		information.informationSort=$(".export-reSearchsort option:selected").val();//分类
  	var value=$(".export-valTime option:selected").val();
  	var array=[];
  	array=YuXi.timestamp.get(null,null,value);	
  	information.startTimestamp=array[0];
  	information.endTimestamp=array[1];
  	//查询数据传送给后台
  	 var url="FirstCheckFilter/firstCheckGetList.do";//地址----------------------------------
  	  YuXi.util.get(url,information,function(data){
  		  	//console.log(data);
  	  		totalPage=data.totalPage;
  	  		$("#export-totalPage").html("1/"+totalPage);
  	  		page=1;	  	
  		  	var object=data.list;
  		  	$("#export-tablebody").html("");
  		
  		  	setData(object);
  			
  		},function(){
  			//console.log("查询失败");
  		});
  		  	/*btn();*/
  }
  $(".btn-exportFirst-query").click(function(){
	  firstSearch();
  });
})

